/**
 * File: kinematic.h
 * Brief:
 * Created by: zhangping
 * Created at: 2017.06.9
 * Modified by:
 * Modified at:
 **/
 
#ifndef _MY_KINEMATIC_H_
#define _MY_KINEMATIC_H_


extern "C++" 
{
    namespace kinematic{
		typedef char U8;
        typedef unsigned short int U16;

        const float kStepAngle = 0.1125;
        const float kWheelRadius = 0.065/2; // from 参考资料中的《步进电机平衡小车入门.pdf》的Page-1.
        const float kPi = 3.1415927; // from 参考资料中的《步进电机平衡小车入门.pdf》的Page-5.
        const float kPace = (kStepAngle/180)*kPi*kWheelRadius; // 一个脉冲的前进距离

       /**
        * Function: LinearVelocityToPulse
        * Brief:
        * Args:
        *     vel: linear velocity, unit is 'm/s'.
        * Return:
        *     the number of pulse, unit is 'number/s'.
        */
        U16 LinearVelocityToPulse(float vel);

       /**
        * Function: RotationVelocityToPluse
        * Brief:
        * Args:
        *     vel: rotation velocity, unit is 'rad/s'.
        * Return:
        *     the number of pulse, unit is 'number/s'.
        */
        U16 RotationVelocityToPluse(float vel);

       /**
        * Function: ComputeDirection
        * Brief: 计算速度控制位。
        * Args:
        *     vel_x: velocity at x-axis，move toward the right.
        *     vel_y: velocity at y-axis, move forward.
        * Return:
        *     direction.
        */
        U8 ComputeDirection(float vel_x, float vel_y, float vel_w);
        
	}
	
}

#endif


